package com.aq.state;


public class TestStop implements Runnable{

    private boolean temp = true;

    @Override
    public void run() {
        int i = 0;
        while (temp){
            System.out.println("run.....Thread" + "第"+ i++ + "次了");
        }
    }


    public void stop(){
        this.temp = false;
    }

    public static void main(String[] args) {
        TestStop testStop = new TestStop();
        new Thread(testStop).start();

        for(int i = 0; i < 1000; i++) {
            System.out.println("main"+i);
            if(i==900){
                testStop.stop();
                System.out.println("====="+"该线程停止了"+"=====");
                // break;  //打破这次for循环
            }

        }
        
        
    }

}
